package com.example.certificate.utils;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public final class FileUtils {

    public static final Map<Object, Integer> hashMap = new HashMap<>();

    /*图片后缀*/
    private static String[] IMG= {"bmp","jpg","jpeg","png","tiff","gif","pcx","tga","exif","fpx","svg","psd",
            "cdr","pcd","dxf","ufo","eps","ai","raw","wmf"};

    /*文档后缀*/
    private static String[] DOCUMENT= {"txt","doc","docx","pdf"};

    /*视频后缀*/
    private static String[] VIDEO= {"mp4","avi","mov","wmv","asf","navi","3pg","mkv","f4v","rmvb","webm"};

    /*音乐后缀*/
    private  static String[] MUSIC= {"wma","mp3","wav","mod","ra","cd","md","asf","aac","vqf","ape","mid","ogg","m4a"};

    static {

        Arrays.asList(IMG).forEach(item ->{
            hashMap.put(item, 1);
        });

        Arrays.asList(DOCUMENT).forEach(item ->{
            hashMap.put(item, 2);
        });

        Arrays.asList(VIDEO).forEach(item ->{
            hashMap.put(item, 4);
        });

        Arrays.asList(MUSIC).forEach(item ->{
            hashMap.put(item, 3);
        });

    }

    public static String getRandomImgName(String FileName) {
        String suffix = FileName.substring(FileName.lastIndexOf("."));
        return UUID.randomUUID().toString() + suffix;
    }


}
